package com.zkteco.fingerprint.config;

import com.zkteco.fingerprint.websocket.FingerprintWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * WebSocket配置类
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    
    @Autowired
    private FingerprintWebSocketHandler fingerprintWebSocketHandler;
    
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(fingerprintWebSocketHandler, "/fingerprint-ws")
                .setAllowedOrigins("*"); // 允许跨域，生产环境建议限制域名
    }
} 